Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports C4F.DevKit.Messaging
Namespace MapiApplication
	Public Partial Class SendMailOptions
	Inherits Form
		Private mail As Mail
		Private manager As MapiManager
		Public Sub New()
			InitializeComponent()
		End Sub
		Public Sub New(ByRef mail As Mail, ByRef manager As MapiManager)
			InitializeComponent()
			Me.mail = mail
			Me.manager = manager
			If Me.mail IsNot Nothing Then
				txtFrom.Text = mail.From
				chkBodyHtml.Checked = mail.IsBodyHtml
				txtReplyTo.Text = mail.ReplyTo
				txtSender.Text = mail.Sender
				cmbSubjectEndoding.Text = mail.SubjectEncoding.ToString()
				cmbMailPriority.Text = mail.Priority.ToString()
				cmbBodyEncoding.Text = mail.BodyEncoding.ToString()
				cmbAlternateView.Text = mail.AlternateViews.ToString()
				cmbDeliveryNotification.Text = mail.DeliveryNotificationOptions.ToString()
			End If
		End Sub
		Private Sub btnOk_Click(ByVal sender As Object, ByVal e As EventArgs)
			'this.manager.CreateCredentialsToSendMail(txtUsername.Text, txtPassword.Text,);
			mail.From = txtFrom.Text
			mail.IsBodyHtml = chkBodyHtml.Checked
			mail.ReplyTo = txtReplyTo.Text
			mail.Sender = txtSender.Text
			Select cmbSubjectEndoding.Text
				Case "ASCII"
                    mail.SubjectEncoding = C4F.DevKit.Messaging.EncodingOptions.ASCII
					Exit Select
				Case "BigEndianUnicode"
                    mail.SubjectEncoding = C4F.DevKit.Messaging.EncodingOptions.BigEndianUnicode
					Exit Select
				Case "Default"
                    mail.SubjectEncoding = C4F.DevKit.Messaging.EncodingOptions.[Default]
					Exit Select
				Case "Unicode"
                    mail.SubjectEncoding = C4F.DevKit.Messaging.EncodingOptions.Unicode
					Exit Select
				Case "UTF32"
                    mail.SubjectEncoding = C4F.DevKit.Messaging.EncodingOptions.UTF32
					Exit Select
				Case "UTF7"
                    mail.SubjectEncoding = C4F.DevKit.Messaging.EncodingOptions.UTF7
					Exit Select
				Case "UTF8"
                    mail.SubjectEncoding = C4F.DevKit.Messaging.EncodingOptions.UTF8
					Exit Select
			End Select
			Select cmbMailPriority.Text
				Case "High"
					mail.Priority = Priorities.High
					Exit Select
				Case "Low"
					mail.Priority = Priorities.Low
					Exit Select
				Case "Normal"
					mail.Priority = Priorities.Normal
					Exit Select
			End Select
			Select cmbDeliveryNotification.Text
				Case "None"
					mail.DeliveryNotificationOptions = DeliveryNotificationOptions.None
					Exit Select
				Case "Never"
					mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Never
					Exit Select
				Case "OnFailure"
					mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
					Exit Select
				Case "OnSuccess"
					mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
					Exit Select
				Case "Delay"
					mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Delay
					Exit Select
			End Select
			Select cmbBodyEncoding.Text
				Case "ASCII"
                    mail.BodyEncoding = C4F.DevKit.Messaging.EncodingOptions.ASCII
					Exit Select
				Case "BigEndianUnicode"
                    mail.BodyEncoding = C4F.DevKit.Messaging.EncodingOptions.BigEndianUnicode
					Exit Select
				Case "Default"
                    mail.BodyEncoding = C4F.DevKit.Messaging.EncodingOptions.[Default]
					Exit Select
				Case "Unicode"
                    mail.BodyEncoding = C4F.DevKit.Messaging.EncodingOptions.Unicode
					Exit Select
				Case "UTF32"
                    mail.BodyEncoding = C4F.DevKit.Messaging.EncodingOptions.UTF32
					Exit Select
				Case "UTF7"
                    mail.BodyEncoding = C4F.DevKit.Messaging.EncodingOptions.UTF7
					Exit Select
				Case "UTF8"
                    mail.BodyEncoding = C4F.DevKit.Messaging.EncodingOptions.UTF8
					Exit Select
			End Select
			Select cmbAlternateView.Text
				Case "Html"
					mail.AlternateViews = AlternateBodyViews.Html
					Exit Select
				Case "Plain"
					mail.AlternateViews = AlternateBodyViews.Plain
					Exit Select
				Case "RichText"
					mail.AlternateViews = AlternateBodyViews.RichText
					Exit Select
				Case "Xml"
					mail.AlternateViews = AlternateBodyViews.Xml
					Exit Select
			End Select
			Me.Close()
		End Sub
		Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As EventArgs)
			Me.Close()
		End Sub
	End Class
End Namespace
